1 using UnityEngine;
2 using
System.Collections;
3 using
System.Collections.Generic;
4
5
6 ///
<summary>
7 ///
nodes should be in the order start, end, control1, control2
8 ///
</summary>
9 public
class GoSplineCubicBezierSolver : AbstractGoSplineSolver
10 {
11     
public GoSplineCubicBezierSolver( List<Vector3> nodes )
12     {
13         _nodes = nodes;
14     }
15     
16
17     
#region AbstractGoSplineSolver
18     
19     
public override void closePath()
20     {
21         
22     }
23     
24     
25     
public override Vector3 getPoint( float t )
26     {
27         
float d = 1f - t;
28         
return d * d * d * _nodes[0] + 3f * d * d * t * _nodes[1] + 3f * d * t * t * _nodes[2] + t * t * t * _nodes[3];
29     }
30
31     
32     
public override void drawGizmos()
33     {
34         
// draw the control points
35         
var originalColor = Gizmos.color;
36         Gizmos.color = Color.red;
37         
38         Gizmos.DrawLine( _nodes[
0], _nodes[1] );
39         Gizmos.DrawLine( _nodes[
2], _nodes[3] );
40         
41         Gizmos.color = originalColor;
42     }
43     
44     
#endregion
45
46 }



Trò chơi Angry Birds trong UNITY Engine 31.706 lượt xem

Gõ tìm kiếm nhanh...